package com.zhengke.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhengke.dao.MemberManagerDao;
import com.zhengke.pojo.NewMemberREntity;
import com.zhengke.pojo.UserTest;
import com.zhengke.service.MemberManagerService;

@Service
public class MemberManagerServiceImpl implements MemberManagerService {
	
	@Autowired
	MemberManagerDao memberManagerDao;

	@Override
	public List<NewMemberREntity> querrAllMemberMethod(Map<String, Object> messageMap) {
		List<Map<String, Object>> memberList = memberManagerDao.querrAllMemberMethod(messageMap);
		//创建集合用于装封装好的集合
		List<NewMemberREntity> newMemberList = new ArrayList<NewMemberREntity>();
		try {
		//遍历集合封装返回的数据
		for(Map<String, Object> map : memberList) {
			NewMemberREntity memberEntity = new NewMemberREntity();
			memberEntity.setUser_id(map.get("user_id")+"");
			memberEntity.setUser_name(map.get("user_name")+"");
			memberEntity.setUser_phone(map.get("user_phone")+"");
			memberEntity.setStatu(map.get("statu")+"");
			memberEntity.setUser_integral(map.get("user_integral")+"");
			memberEntity.setUser_balance(map.get("user_balance")+"");
			memberEntity.setProvince_name(map.get("province_name")+"");
			memberEntity.setCity_name(map.get("city_name")+"");
			memberEntity.setService_point_name(map.get("service_point_name")+"");
			memberEntity.setAddress_detail(map.get("address_detail")+"");
			memberEntity.setDelivery_way(map.get("delivery_way")+"");
			memberEntity.setUser_home_phone(map.get("user_home_phone")+"");
			memberEntity.setUser_card_number(map.get("user_card_number")+"");
			String receptTimeString = (String) map.get("receipt_time");
			String creatTimeString = (String) map.get("create_time");
			memberEntity.setReceipt_time(receptTimeString);
			memberEntity.setCreate_time(creatTimeString);
			newMemberList.add(memberEntity);
		}
		}catch(Exception e) {
			e.getStackTrace();
		}
		return newMemberList;
	}

	@Override
	public int deleteUserByID(String userid) {
		
		return memberManagerDao.deleteUserByID(userid);
	}

	@Override
	public int activationUserById(String id) {
		
		return memberManagerDao.activationUserById(id);
	}

	@Override
	public int disableUserById(String id) {
		
		return memberManagerDao.disableUserById(id);
	}

	@Override
	public String querryStatuById(String id) {
		
		return memberManagerDao.querryStatuById(id);
	}

	@Override
	public int inSerectUserMethod(UserTest userTest) {
		
		return memberManagerDao.inSerectUserMethod(userTest);
	}

	
}
